﻿using Volo.Abp.DependencyInjection;
using YAPACS.BusinessObjects.Exams;
using YAPACS.Workflows;

namespace YAPACS.RisServer.Workflows.Technician;

public class GetCheckParameterRecordView : WorkflowBase, IGetCheckParameterRecordView, ITransientDependency
{
    protected override async Task<WorkflowOutput> InvokeCoreAsync(WorkflowInput input)
    {
        WorkflowOutput workflowOutput = new()
        {
            Success = true,
            View = await Extensions.GetResourceStringAsync("Resources.Technician.check-parameter-record.json"),
            ViewTitle = "记录检查参数",
            NextAction = "技师-检查参数记录",
            NextActionCaption = "记录",
            ViewWidth = "50%"
        };
        const string key = "Exam";
        if (input.ContainsKey(key) && input.GetValueOrDefault(key) is Exam exam)
        {
            exam.ExamRecordParamsJson.Add("schema", workflowOutput.View);
            workflowOutput.Data = exam.ExamRecordParamsJson;
        }
        return workflowOutput;
    }
}
